#include "main_window.h"
#include "ui_main_window.h"

namespace
{

inline QString org()
{
    return "iam";
}

inline QString app()
{
    return "kpp";
}

}

main_window::main_window(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::main_window)
{
    ui->setupUi(this);

    load_layout();
}

main_window::~main_window()
{
    save_layout();
    delete ui;
}

void main_window::save_layout()
{
    QSettings set(org(), app());

    set.setValue("main_geometry", saveGeometry());
    set.setValue("main_state"   , saveState());
}

void main_window::load_layout()
{
    const QSettings set(org(), app());

    restoreGeometry(set.value("main_geometry").toByteArray());
    restoreState   (set.value("main_state"   ).toByteArray());
}
